//
//  EpointLoadUserHeadImageTask.m
//  EpointFrame5
//
//  Created by 李亚春 on 14-3-3.
//  Copyright (c) 2014年 Epoint. All rights reserved.
//

#import "EpointLoadUserHeadImageTask.h"
#import "HttpUtil.h"
#import "EpointIOUtil.h"

@implementation EpointLoadUserHeadImageTask

-(void)execute
{
    NSString *UserGuid =(NSString *)[DBFrameService getUserDefaults:Epoint_User_UserGuid];
    NSString *dirPath = [NSString stringWithFormat:@"%@/Documents/photos/%@.jpg",NSHomeDirectory(),UserGuid];
    NSString *bs = [HttpUtil getStr:[EpointBizTools getUserHeadImageUrl:UserGuid]];
    if ([bs isEqualToString:@"Success"]) {
        NSString *headUrl = [EpointBizTools getUrl:[NSString stringWithFormat:@"mobiletmp/%@.jpg",UserGuid]];
        NSData *data = [HttpUtil getData:headUrl];
        [EpointIOUtil writeToFile:dirPath withData:data];
        [self exeSuccessWithData:dirPath];
    }
}

@end
